<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title>个人资料 - 期金管家</title>
    <!-- Bootstrap CSS -->
<!--    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
          integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

    <link rel="stylesheet" href="/static/home/css/common.css">-->

</head>
<script type="text/javascript">
    var change=function(o){
        //限制只数字
        o.value=o.value.replace(/\D/g,'').substring(0,4);//长度限制，7是长度
    };

</script>

<body>
<!--HEADER-->
{include file="Public/header"/}
<!--HEADER-->

<div class="container personalInfo">
    <div class="row">
        {include file="Public/readme"/}
        <div class="col-md-9">
            <ul class="nav nav-tabs mb-4" role="tablist">
                <li class="nav-item">
                    <a class="nav-link bg-dark text-white active" href="#home" role="tab" data-toggle="tab">个人资料</a>
                </li>
            </ul>
            <div class="tab-content row">
                <div class="col-sm-4 text-center">
                    <a href="#"><img src="/static/home/images/imgHead.jpg" alt="个人头像" class="img-circle"></a>
                </div>
                <div class="col-sm-8">
                    <table class="table table-hover modifyData">
                        <tr>
                            <th scope="row" class="text-right">真实姓名：</th>
                            <td>{$list.names}</td>
                        </tr>
                        <tr>
                            <th scope="row" class="text-right">身份证号：</th>
                            <td colspan="2">
                                {if condition = "$ste.RNA == 1"}
                                {$list.IDnumbers}
                                {/if}
                            </td>
                        </tr>
                        <tr>
                            <th scope="row" class="text-right">手机：</th>
                            <td>{$ste.phonenumber}</td>
                        </tr>
                        <tr class="hideTr">
                            <th scope="row" class="text-right">旧手机验证码：</th>
                            <td>
                                <div class="form-group">
                                    <label class="sr-only">旧手机验证码</label>
                                    <div class="input-group">
                                        <input oninput="change(this)" onpropertychange="change(this)" type="text"   class="form-control" name="oldcode" value="">
                                        <div class="input-group-btn">
                                            <!--<div class="btn btn-default" id="oldcode">获取验证码</div>-->
                                            <input type="button" class="btn btn-default" id="oldcode" value="获取验证码"/>
                                        </div>
                                    </div>
                                </div>
                            </td>
                            <td><p class="help-block"></p></td>
                        </tr>
                        <tr class="hideTr">
                            <th scope="row" class="text-right">新手机：</th>
                            <td>
                                <div class="form-group">
                                    <label class="sr-only">新手机</label>
                                    <input type="text" class="form-control" name="newmobile" value="">
                                </div>
                            </td>
                            <td><p class="help-block"></p></td>
                        </tr>
                        <tr class="hideTr">
                            <th scope="row" class="text-right">新手机验证码：</th>
                            <td>
                                <div class="form-group">
                                    <label class="sr-only">新手机验证码</label>
                                    <div class="input-group">
                                        <input  oninput="change(this)" onpropertychange="change(this)" type="text" class="form-control" name="newcode" value="">
                                        <div class="input-group-btn">
                                            <!--<div class="btn btn-default" id="newcode">获取验证码</div>-->
                                            <input type="button" class="btn btn-default" id="newcode" value="获取验证码"/>
                                        </div>
                                    </div>
                                </div>
                            </td>
                            <td><p class="help-block"></p></td>
                        </tr>
                        <tr class="text-center">
                            <td colspan="3"><a class="btn btn-primary btnModifyData" href="#" id="btnBud">修改手机号</a></td>
                        </tr>
                        <tr class="text-center hide">
                            <td colspan="3"><a class="btn btn-primary btnModifyData" href="#" id="btnSave">保存资料</a></td>
                        </tr>
                    </table>

                </div>
            </div>
        </div>

    </div>
</div>
<br /><br /><br /><br /><br />
<!--footer-->
{include file="Public/footer"/}
<!--footer-->

<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<!--
<script src="/static/home/js/personal_head_menu.js"></script>-->
<script type="text/javascript" src="/static/home/js/validate/jquery.validate.js"></script>
<script type="text/javascript" src="/static/home/js/validate/additional-methods.js"></script>
</body>
</html>
<script>
    $(document).ready(function () {
        $(".SideGrzl").addClass("panel-primary");
    });

</script>

<script>
    $(function () {
        $("#oldcode").click(function () {
            //调用获取验证码60S函数
            settime(this);
            var s = 'modify';
            var mobile = "{$ste.phonenumber}";
            $.post('/home/Personal/passwordCode', {s: s, mobile: mobile}, function (data) {
                var olds = JSON.parse(data);
                if (olds.msg == 'success') {
                    alert('发送成功');
                } else {
                    alert(olds.msg);
                }
            })
        });

        //验证码手机是否被注册
        $("input[name='newmobile']").focus(function () {

        }).blur(function () {
            var mobiles = $("input[name='newmobile']").val();
            if (mobiles.match(/(^1[3|4|5|6|7|8|9]\d{9}$)|(^09\d{8}$)/) == null) {
                alert('手机格式错误或未添加');
            } else {
                $.post('/home/Personal/Verificationmobile', {mobiles: mobiles}, function (data) {
                    var vs = JSON.parse(data);
                    if (vs.msg != 'success') {
                        alert(vs.msg);
                    }
                });
            }

        })

        //新
        $("#newcode").click(function () {
            //调用获取验证码60S函数
            settimeTel(this);
            var s = 'modify';
            var mobile = $("input[name='newmobile']").val();
            var oldmobile = {$ste.phonenumber};
        // alert(mobile)
        if (mobile.match(/(^1[3|4|5|6|7|8|9]\d{9}$)|(^09\d{8}$)/) != null || !mobile) {
            if (mobile != oldmobile) {
                $.post('/home/Personal/passwordCode',{mobile:mobile,s:s},function(datas) {
                    var news = JSON.parse(datas);
                    // alert(news.msg)
                    if (news.msg == 'success') {
                        alert('发送成功');
                    }else{
                        alert(news.msg);
                    }
                });
            } else {
                alert('手机账号不能一样')
            }
        } else {
            $(".msg03").html("手机格式错误或未添加").addClass("fontRed");
        }

    });

    });

    $(function () {
        $(".hideTr").hide();
        $("#btnBud").click(function () {
            $(".hideTr").show();
            $("#btnBud").parent("td").parent("tr").hide();
            $("#btnSave").parent("td").parent("tr").removeClass("hide");

        })

    })

    $(function () {
        $("#btnSave").click(function () {
            var mobile = $("input[name='newmobile']").val();//新
            var oldmobile = {$ste.phonenumber};//旧
        var oldcode = $("input[name='oldcode']").val();
        var newcode = $("input[name='newcode']").val();

        if (mobile != oldmobile && mobile && oldcode && newcode) {
            // alert('ky');
            $.post('__ROOT__/home/Personal/editphoneNumber', {
                mobile: mobile,
                oldmobile: oldmobile,
                oldcode: oldcode,
                newcode: newcode
            }, function (data) {
                var datas = JSON.parse(data);
                if (datas.msg == 'success') {
                    alert('成功');
                    window.location.reload();
                } else {
                    alert(datas.msg);
                }
            });
        } else {
            alert('请检查资料在提交');
        }

    })

    });


    //获取验证码60S函数
    var countdown = 60;
    function settime(obj) {
        if (countdown == 0) {
            obj.removeAttribute("disabled");
            obj.value = "获取验证码";
            countdown = 60;
            return;
        } else {
            obj.setAttribute("disabled", true);
            obj.value = "重新发送(" + countdown + ")";
            countdown--;
        }
        setTimeout(function () {
                    settime(obj)
                }
                , 1000)
    }
    //获取验证码60S函数
    var countdownTel = 60;
    function settimeTel(obj) {
        if (countdownTel == 0) {
            obj.removeAttribute("disabled");
            obj.value = "获取验证码";
            countdownTel = 60;
            return;
        } else {
            obj.setAttribute("disabled", true);
            obj.value = "重新发送(" + countdownTel + ")";
            countdownTel--;
        }
        setTimeout(function () {
                    settimeTel(obj)
                }
                , 1000)
    }
    //手机底部菜单选中样式
    // $(".menuFoot").find("a").eq(1).addClass("active");

    $(".fixed-bottom").find("li").each(function(){
        $(this).find("a").removeClass("active");
    });
    $(".fixed-bottom").find("li").eq(3).find("a").addClass("active");

</script>